AC_INIT(README)
AC_CANONICAL_SYSTEM
AC_PREREQ(2.13)
AM_INIT_AUTOMAKE(OptionParser, 1.0)
AM_MAINTAINER_MODE

AC_PROG_INSTALL

dnl pkg-config
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
	AC_MSG_ERROR([You need to install pkg-config])
fi

MONO_REQUIRED_VERSION=0.91
PKG_CHECK_MODULES(MONO, mono >= $MONO_REQUIRED_VERSION)

MONODIR=`$PKG_CONFIG --variable=exec_prefix mono`
MONOBIN="$MONODIR/bin"
MONO="$MONOBIN/mono"
MINT="$MONIBIN/mint"
MCS="$MONOBIN/mcs"
GACUTIL="$MONOBIN/gacutil"

if test ! -x "$MONO" -a ! -x "$MINT"; then
	AC_MSG_ERROR([No mono runtime found])
fi

if test ! -x "$MONO"; then
	MONO = $MINT
fi

CS="C#"
if test ! -x "$MCS"; then
	AC_MSG_ERROR([No $CS compiler found])
fi

if test ! -x "$GACUTIL"; then
	AC_MSG_ERROR([No mono gacutil found])
fi

AC_SUBST(MCS)
AC_SUBST(MONO)
AC_SUBST(GACUTIL)

AC_OUTPUT([
Makefile
OptionParser.pc
OptionParser.spec
src/Makefile
src/AssemblyInfo.cs
test/Makefile
])

